<?php
namespace Admin\Controller;
use Think\Controller;

class CommonController extends Controller {
    
    public function _initialize(){
        
    }
    
    public function __construct(){
        parent::__construct();
        //检测是否登录
        if(!session('?admin') || !session('?adminlevel') || !session('?logintime'))
        {
            session(null);
            session('[destroy]');
            $this->redirect('Login/index');
            exit();
        }
    }

    public function uploadImg(){

        $upload = new \Think\Upload();// 实例化上传类

        $upload->maxSize   =     3145728 ;// 设置附件上传大小
        $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->rootPath  =     './Uploads/'; // 设置附件上传根目录
        $upload->savePath  =     ''; // 设置附件上传（子）目录
        // 上传文件 
        $info   =   $upload->upload();

        $res = convert_arr_keys($info,'key');
        return $res;
    }
    
}